home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: lewkbj@ix.netcom.com(leonel wizel )
- Newsgroups: comp.lang.c++
- Subject: I need help with homework (Please)
- Date: 15 Mar 1996 02:53:00 GMT
- Organization: Netcom
- Message-ID: <4iam2c$1i7@cloner3.netcom.com>
- NNTP-Posting-Host: ix-nyc18-14.ix.netcom.com
- X-NETCOM-Date: Thu Mar 14 6:53:00 PM PST 1996
-
-
- I have written the following program that contains double subscripted arrays that provides
- me with the following:
-
- salesperson Number 1 to 4
- the product number from 1 to 5
-
- at the end provides me, with the summarization that includes total products by salesperson
- number horizontally, and prints total by product number vertically, but I am missing a way
- to input also the total by dollar value in the same way.
-
- I need help please:
-
- the program is as follows:
-
-
- //program prints salespersons products by number and adds them
- //by salesperson number and product number
-
- #include <iostream.h>
- #include <iomanip.h>
- #include <math.h>
-
- const int S_person = 4; //number of salespersons
- const int prod_sold = 5; //number of products
-
- void Print_Table (float[][S_person], int, int);
- void Total_Sales_Person (float[][S_person], int, int);
-
- main()
- {
- float table[prod_sold][S_person];
-
- for (int x = 0; x < S_person; x++)
- {
-
- cout << endl;
- cout << "Enter the product sold by Sales Person# ["<<(x+1)<<"] one at a time: "<< endl;
- cout << endl;
-
- for (int y = 0; y < prod_sold; y++)
- {
- cout << "Enter product ["<<(y+1)<<"] sold by Sales Person# ["<<(x+1)<<"]: ";
- cin >> table[y][x];
- }
- }
- Print_Table(table, prod_sold, S_person);
- return 0;
- }
-
- //function Print_Table prints the cable of contents
-
- void Print_Table (float sales[][S_person], int prod_sold, int S_person)
- {
- float total_prod_sold;
-
- cout << endl;
-
- cout << setw(26) << "sales#[1]" << setw(12) <<"sales#[2]" << setw(12)
- <<"sales#[3]" <<setw(12) << "sales#[4]" << setw(9) <<"Total"
- <<endl;
- cout << endl;
-
- for (int y = 0; y < prod_sold; y++)
- {
- cout << endl;
- cout << setw(8) <<"product["<<(y+1)<<"]";
- total_prod_sold = 0;
-
- for (int x = 0; x < S_person; x++)
- {
- total_prod_sold += sales[y][x];
-
- cout << setw(12) << sales[y][x];
- }
- cout << setw(12) << total_prod_sold;
- }
-
- Total_Sales_Person(sales, prod_sodl, S_person);
- return;
- }
-
- //function Total_Sales_Person ( adds the total)
-
- void Total_Sales_Person (float set_of_sale[][S_person], int prod_sold, int S_person)
- {
- float total_sale;
-
- cout << endl;
-
- cout << setw(8) <<"Total Sale" << endl;
-
- for (int x = 0; x < S_person; x++)
- {
- total_sale = 0;
-
- for (int y = 0; y < prod_sold; y++)
- total_sale += set_of_sale[y][x];
-
- cout << endl;
- cout << setw(15) << total_sale << endl;
- }
- return;
- }
-
- I do not know how to improve this program to input/output the total
- price in dollars by the products;
-
- I need to do the following:
-
- use a double-subscripted array to solve the following problem. A
- company has four sales-people (1-4) who sell five different products (1
- to 5). Once a day, each sales person passes in a slip for each
- different type of product sold> Each slip contains:
-
- 1. The salesperson number
- 2. The product number
- 3. The total dollar value of that product sold that day
-
- the program should print a tabular that includes: these cross totals to
- the right of the totaled rows and to the bottom of the totaled columns.
-
- I was able to solve the prolem of printing the rows of salesitems to
- the right and total by salesperson to the bottom but I have to print
- the total of the product by dollar sign which I do not have now.
-
- Please I need some help
-
-
- I appreciate your cooperation.
-
-